package Window;

import javax.swing.*;
import java.awt.*;

public class WindowMenu extends JFrame{
    JMenuBar menuBar;
    JMenu menu,submenu;
    JMenuItem item1,item2;

    JCheckBox checkBox1,checkBox2,checkBox3;
    JRadioButton radioButton1,radioButton2;
    ButtonGroup group;
    JComboBox<String> comboBox;

    Box boxH;//行式盒
    Box boxVone,boxVtwo;//列式盒

    public WindowMenu(String s,int x,int y,int w,int h){
        init(s);
        setLocation(x,y);
        setSize(w,h);
        setVisible(true);
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);


    }
    void init(String s){
        setTitle(s);
        menuBar=new JMenuBar();
        menu =new JMenu("菜单");
        submenu=new JMenu("Java程序设计");
        item1=new JMenuItem("Java初级",new ImageIcon(""));
        item2=new JMenuItem("Java高级",new ImageIcon(""));
        menu.add(item1);
        menu.addSeparator();
        menu.add(item2);
        menu.addSeparator();
        menu.add(submenu);
        submenu.add(new JMenuItem("JavaEE项目实战"));
        submenu.add(new JMenuItem("JavaWeb网站设计"));
        menuBar.add(menu);
        setJMenuBar(menuBar);

        setLayout(new FlowLayout());
        comboBox=new JComboBox<String>();
        checkBox1=new JCheckBox("旅游");
        checkBox2=new JCheckBox("音乐");
        checkBox3=new JCheckBox("运动");
        group=new ButtonGroup();
        radioButton1=new JRadioButton("男");
        radioButton2=new JRadioButton("女");
        group.add(radioButton1);
        group.add(radioButton2);
        add(checkBox1);
        add(checkBox2);
        add(checkBox3);
        add(radioButton1);
        add(radioButton2);
        comboBox.addItem("百度一下");
        comboBox.addItem("Google");
        comboBox.addItem("搜狗");
        add(comboBox);

        boxH=Box.createHorizontalBox();
        boxVone=Box.createVerticalBox();
        boxVtwo=Box.createVerticalBox();
        boxVone.add(new JLabel("姓名："));
        boxVone.add(new JLabel("密码："));
        boxVtwo.add(new JTextField(10));
        boxVtwo.add(new JPasswordField(10));
        boxH.add(boxVone);
        boxH.add(Box.createHorizontalStrut(10));
        boxH.add(boxVtwo);
        add(boxH);

    }
}
